//
//  ZpStatusViewModel.m
//  WeiBo_OC
//
//  Created by MacBook Pro on 16/5/30.
//  Copyright © 2016年 MacBook Pro. All rights reserved.
//

#import "ZpStatusViewModel.h"
#import "UIImageView+WebCache.h"
@implementation ZpStatusViewModel

- (instancetype)initWithDict:(NSDictionary *)dict{
    if (self = [super init]) {
        self.status = [ZpStatus statusWithDict:dict];
        [self setParamster];
    }
    return self;
}

- (void)setParamster{
    self.iconUrl = [NSURL URLWithString:self.status.user.profile_image_url];
    NSString *tmp = self.status.source;
    if (tmp.length > 0) {
        NSRange start = [tmp rangeOfString:@">"];
        tmp = [tmp substringFromIndex:start.location+1];
        NSRange end = [tmp rangeOfString:@"</a>"];
        tmp  = [tmp substringToIndex:end.location];
    }
    
    self.source = tmp;
    
    self.time = @"21:10";
    if (self.status.user.mbrank){
        self.mbrankImage =[UIImage imageNamed:[NSString stringWithFormat:@"common_icon_membership_level%ld", self.status.user.mbrank]];
    }else{
        self.mbrankImage = nil;
    }
    
    if (self.status.user.verified) {
        self.veritiedImage = [UIImage imageNamed:@"avatar_vip"];
    }else{
        self.veritiedImage = nil;
    }
}

@end
